import axios from 'axios';
import store from './store'

// 自己补充环境的判断  process.env.NODE_ENV

const http = axios.create({
  baseURL: '/api',
  timeout: 1000
})

// 拦截器
http.interceptors.request.use(config => {
  if(config.url != "/userlogin") {
    // 登录的接口不需要token
    config.headers.authorization = store.state.userInfo.token;
  }
  return config
})

http.interceptors.response.use(data => {
  return data.data
})
export default http